#define _CRT_SECURE_NO_WARNINGS 1

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */

typedef struct TreeNode TNode;

//  void swap(int* num1, int* num2)
//  {
//     int tmp = *num1;
//     *num1 = *num2;
//     *num2 = tmp;
// }

// void  _invertTree(struct TreeNode* left, struct TreeNode* right)
// {
//     if(left == NULL && right == NULL)
//     {
//         return;
//     }

//     swap(&left->val,&right->val);
//     _invertTree(left->left,right->right);
//     _invertTree(left->right,right->left);
// }

// struct TreeNode* invertTree(struct TreeNode* root) {
//     if(root == NULL)
//         return NULL;

//     _invertTree(root->left, root->right);

//     return root;
// }

struct TreeNode* invertTree(struct TreeNode* root) {
    if (root == NULL)
        return NULL;

    TNode* left = invertTree(root->left);
    TNode* right = invertTree(root->right);

    root->left = right;
    root->right = left;

    return root;
}

